SEQ

Seq is a trait which represents indexed sequences that are guaranteed immutable. You can access elements by using their indexes. It maintains insertion order of elements.

Sequences support a number of methods to find occurrences of elements or subsequences. It returns a list.

import scala.collection.immutable._  
object MainObject{  
    def main(args:Array[String]){  
        var seq:Seq[Int] = Seq(52,85,1,8,3,2,7)  
        seq.foreach((element:Int) => print(element+" "))  
        println("\nAccessing element by using index")  
        println(seq(2))  
    }  
}  

No comments:

Post a Comment